home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 0562.ZIP / SUBPATH.BAS < prev    next >
BASIC Source File  |  1987-03-29  |  3KB  |  60 lines

  1. 10 'This routine, in combination with associated BAT files, will subtract           a directory search path from an existing path.
  2. 20 '
  3. 30 'In order to pass a parameter (in this case, the directory path to be added)     into a BASIC program, the first executed BAT file, SUBPATH.BAT, places the
  4. 40 'parameter (the path to be deleted)into an environment section                   (see the DOS SET command) that is accessible through BASIC.
  5. 50 '
  6. 60 'This program then creates yet another BAT file that executes the new path       command and cleans up all of the intermediate files and environments.
  7. 70 OPEN "subpath.dat" FOR INPUT AS 1         'Output from PATH command, Created                                               by SUBPATH.BAT
  8. 80 LINE INPUT #1, A$                         'Read it into a$
  9. 90  'Change it all to upper case
  10. 100 PLEN=LEN(A$)
  11. 110 FOR I = 1 TO PLEN
  12. 120 AV = ASC(MID$(A$,I,1))
  13. 130 IF AV > 96 AND AV <123 THEN AV=AV-32: MID$(A$,I,1)=CHR$(AV)
  14. 140 NEXT I
  15. 150 PARM$=ENVIRON$("PAT")
  16. 160 OPEN "subpat.bat" FOR OUTPUT AS 2         'To create a new BAT file
  17. 170 PARMLEN=LEN(PARM$)
  18. 180 IF PARMLEN=0 THEN GOTO 420
  19. 190  'Change input parm to all upper case
  20. 200 FOR I = 1 TO PARMLEN
  21. 210 PV = ASC(MID$(PARM$,I,1))
  22. 220 IF PV > 96 AND PV <123 THEN PV=PV-32: MID$(PARM$,I,1)=CHR$(PV)
  23. 230 NEXT I
  24. 240 IF A$="NO PATH" THEN A$="":GOTO 380      'PATH command output is "No Path"                                                if there was no previous path.                                                  This sets it to blank.
  25. 250 PATHLEN=LEN(A$)
  26. 260 FOR I=1 TO PATHLEN-PARMLEN+1
  27. 270 IF MID$(A$,I,PARMLEN)=PARM$ THEN IPOS=I: GOTO 440 'Found the string
  28. 280 NEXT I
  29. 290 GOTO  390   'Not found
  30. 300 REM:  Create a batch file for doing the new SET PATH= command
  31. 310 PRINT #2, "ECHO Setting "+NEWPATH$              'Display the new path
  32. 320 PRINT #2, "SET "+NEWPATH$                 'Issues SET PATH= command,                                                       with desired path deleted.
  33. 330 PRINT #2, "SUBPATH"                       'Go back to DELETE SUBPAT.BAT
  34. 340 CLOSE #1
  35. 350 KILL "subpath.dat"                        'Delete the intermediate file
  36. 360 CLOSE
  37. 370 SYSTEM
  38. 380 PRINT "The current PATH is empty.  ";: GOTO 430
  39. 390 PRINT "The path element requested for deletion does not exist."
  40. 400 PRINT " Run the PATH command without parameters to see the current PATH."
  41. 410            GOTO 430
  42. 420 PRINT "No pathname entered.   ";:GOTO 430
  43. 430 COLOR 14,0: PRINT "No action has been taken.": COLOR 7,0: GOTO 330
  44. 440 REM String found
  45. 450    NEWPATH$=LEFT$(A$,IPOS-1) +                                                              RIGHT$(A$,PATHLEN-IPOS-PARMLEN+1)
  46. 460    NEWLEN=LEN(NEWPATH$)
  47. 470 REM Scan for double semi-colons left over
  48. 480    FOR J = 1 TO NEWLEN-1
  49. 490    IF MID$(NEWPATH$,J,2)=";;" THEN IPOS=J:                                              NEWPATH$=LEFT$(NEWPATH$,IPOS-1)+RIGHT$(NEWPATH$,NEWLEN-IPOS):                   NEWLEN=NEWLEN-1:  GOTO 480
  50. 500    NEXT J
  51. 510 REM Is there a trailing semicolon?
  52. 520    IF MID$(NEWPATH$,NEWLEN,1)=";" THEN NEWPATH$=LEFT$(NEWPATH$,NEWLEN-1):             NEWLEN=NEWLEN-1
  53. 530 REM Is there a leading semicolon?
  54. 540    IF MID$(NEWPATH$,6,1)=";" THEN                                                     NEWPATH$=LEFT$(NEWPATH$,5)+RIGHT$(NEWPATH$,NEWLEN-6):                           NEWLEN=NEWLEN-1
  55. 550    GOTO 300
  56. 00
  57. EN=NEWLEN-1
  58. 550    GOTO 300
  59. 
  60.